package 测试;

public class 表达式的合法性判断 {

	public static void main(String[] args) {

	}

}

class ChkExpression {
	public boolean chkLegal(String A) {
		int a = 0, b = 0, c = 0;
		for (int i = 0; i < A.length(); i++) {
			char x = A.charAt(i);
			if (x == '{')
				a++;
			else if (x == '[')
				b++;
			else if (x == '(')
				c++;
			else if (x == '}')
				a--;
			else if (x == ']')
				b--;
			else if (x == ')')
				c--;
		}
		if (a != 0 || b != 0 || c != 0)
			return false;
		return true;
	}
}